<template>
  <el-dialog
    title="投保数据"
    :visible.sync="dialogVisible"
    width="500px"
    append-to-body
  >
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="订单id">
        {{ form.orderId }}
        <!-- <el-input v-model="form.id" type="text" disabled /> -->
      </el-form-item>
      <el-form-item label="保费（元）">
        ¥{{ form.premium/100 }}
      </el-form-item>
      <el-form-item label="保单缴费单号">
        {{ form.exchangeNo }}
      </el-form-item>
      <el-form-item label="保单号">
        {{ form.policyNo }}
      </el-form-item>
      <el-form-item label="保险开始时间">
        {{ form.insuranceStartTime }}
      </el-form-item>
      <el-form-item label="保险结束时间">
        {{ form.insuranceEndTime }}
      </el-form-item>
      <el-form-item label="保险投保时间">
        {{ form.insureDate }}
      </el-form-item>
      <el-form-item label="保单地址">
        <a
          class="download"
          :href="form.policyUrl"
          target="_blank"
          download
        >下载</a>
      </el-form-item>
    </el-form>
    <div
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        type="primary"
        @click="dialogVisible=false"
      >关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
// import { getTWCLog } from '@/api/aliPayTWC'
// import customPage from '@/components/customPage'
import { twcInsuranceGet } from '@/api/aliPayTWC'
export default {
  // components: { customPage },
  props: ['orderId'],
  data() {
    return {
      activeName: 'deduct',
      dialogVisible: false,
      form: {
        orderId: 0,
        premium: 0,
        exchangeNo: 0,
        policyNo: 0,
        insuranceStartTime: 0,
        insuranceEndTime: 0,
        insureDate: 0,
        policyUrl: ''

      }
      // total: 0
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getDeduct()
        })
      }
    }
  },
  methods: {
    getDeduct() {
      twcInsuranceGet({ orderId: this.orderId }).then(res => {
        this.form = JSON.parse(res.data.response_data)
        // this.isOpenTWC = true
        console.log(res)
      })
    }
  }
}
</script>

<style>
.download{
  color: rgb(39, 95, 237);
}
</style>
